/**
 */
package org.mro.grib.model.files.secondEdition.dataRepresentations.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.mro.grib.model.files.secondEdition.dataRepresentations.DataRepresentationTemplate551;
import org.mro.grib.model.files.secondEdition.dataRepresentations.DataRepresentationsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Data Representation Template551</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate551Impl#getP <em>P</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate551Impl#getJs <em>Js</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate551Impl#getKs <em>Ks</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate551Impl#getMs <em>Ms</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate551Impl#getTs <em>Ts</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate551Impl#getUnpackedSubsetPrecision <em>Unpacked Subset Precision</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DataRepresentationTemplate551Impl extends DataRepresentationTemplate550Impl implements DataRepresentationTemplate551 {
	/**
	 * The default value of the '{@link #getP() <em>P</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getP()
	 * @generated
	 * @ordered
	 */
	protected static final int P_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getP() <em>P</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getP()
	 * @generated
	 * @ordered
	 */
	protected int p = P_EDEFAULT;

	/**
	 * The default value of the '{@link #getJs() <em>Js</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJs()
	 * @generated
	 * @ordered
	 */
	protected static final short JS_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getJs() <em>Js</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJs()
	 * @generated
	 * @ordered
	 */
	protected short js = JS_EDEFAULT;

	/**
	 * The default value of the '{@link #getKs() <em>Ks</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getKs()
	 * @generated
	 * @ordered
	 */
	protected static final short KS_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getKs() <em>Ks</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getKs()
	 * @generated
	 * @ordered
	 */
	protected short ks = KS_EDEFAULT;

	/**
	 * The default value of the '{@link #getMs() <em>Ms</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMs()
	 * @generated
	 * @ordered
	 */
	protected static final short MS_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getMs() <em>Ms</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMs()
	 * @generated
	 * @ordered
	 */
	protected short ms = MS_EDEFAULT;

	/**
	 * The default value of the '{@link #getTs() <em>Ts</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTs()
	 * @generated
	 * @ordered
	 */
	protected static final int TS_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getTs() <em>Ts</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTs()
	 * @generated
	 * @ordered
	 */
	protected int ts = TS_EDEFAULT;

	/**
	 * The default value of the '{@link #getUnpackedSubsetPrecision() <em>Unpacked Subset Precision</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUnpackedSubsetPrecision()
	 * @generated
	 * @ordered
	 */
	protected static final byte UNPACKED_SUBSET_PRECISION_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getUnpackedSubsetPrecision() <em>Unpacked Subset Precision</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUnpackedSubsetPrecision()
	 * @generated
	 * @ordered
	 */
	protected byte unpackedSubsetPrecision = UNPACKED_SUBSET_PRECISION_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DataRepresentationTemplate551Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DataRepresentationsPackage.Literals.DATA_REPRESENTATION_TEMPLATE551;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getP() {
		return p;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setP(int newP) {
		int oldP = p;
		p = newP;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__P, oldP, p));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getJs() {
		return js;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setJs(short newJs) {
		short oldJs = js;
		js = newJs;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__JS, oldJs, js));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getKs() {
		return ks;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setKs(short newKs) {
		short oldKs = ks;
		ks = newKs;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__KS, oldKs, ks));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getMs() {
		return ms;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMs(short newMs) {
		short oldMs = ms;
		ms = newMs;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__MS, oldMs, ms));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getTs() {
		return ts;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTs(int newTs) {
		int oldTs = ts;
		ts = newTs;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__TS, oldTs, ts));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getUnpackedSubsetPrecision() {
		return unpackedSubsetPrecision;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUnpackedSubsetPrecision(byte newUnpackedSubsetPrecision) {
		byte oldUnpackedSubsetPrecision = unpackedSubsetPrecision;
		unpackedSubsetPrecision = newUnpackedSubsetPrecision;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__UNPACKED_SUBSET_PRECISION, oldUnpackedSubsetPrecision, unpackedSubsetPrecision));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__P:
				return getP();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__JS:
				return getJs();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__KS:
				return getKs();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__MS:
				return getMs();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__TS:
				return getTs();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__UNPACKED_SUBSET_PRECISION:
				return getUnpackedSubsetPrecision();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__P:
				setP((Integer)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__JS:
				setJs((Short)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__KS:
				setKs((Short)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__MS:
				setMs((Short)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__TS:
				setTs((Integer)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__UNPACKED_SUBSET_PRECISION:
				setUnpackedSubsetPrecision((Byte)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__P:
				setP(P_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__JS:
				setJs(JS_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__KS:
				setKs(KS_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__MS:
				setMs(MS_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__TS:
				setTs(TS_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__UNPACKED_SUBSET_PRECISION:
				setUnpackedSubsetPrecision(UNPACKED_SUBSET_PRECISION_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__P:
				return p != P_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__JS:
				return js != JS_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__KS:
				return ks != KS_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__MS:
				return ms != MS_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__TS:
				return ts != TS_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE551__UNPACKED_SUBSET_PRECISION:
				return unpackedSubsetPrecision != UNPACKED_SUBSET_PRECISION_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (p: "); //$NON-NLS-1$
		result.append(p);
		result.append(", js: "); //$NON-NLS-1$
		result.append(js);
		result.append(", ks: "); //$NON-NLS-1$
		result.append(ks);
		result.append(", ms: "); //$NON-NLS-1$
		result.append(ms);
		result.append(", ts: "); //$NON-NLS-1$
		result.append(ts);
		result.append(", unpackedSubsetPrecision: "); //$NON-NLS-1$
		result.append(unpackedSubsetPrecision);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate550Impl#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) {
		super.initialise(buffer);
		p = buffer.getInt();
		js = buffer.getShort();
		ks = buffer.getShort();
		ms = buffer.getShort();
		ts = buffer.getInt();
		unpackedSubsetPrecision = buffer.get();
	}
	
} //DataRepresentationTemplate551Impl
